/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */

/*
 * MenuForm.java
 *
 * Created on 07/02/2011, 12:16:04 PM
 */
package cuadroanotacion.start;

import cuadroanotacion.equipos.EquiposListar;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;
import javax.swing.JInternalFrame;
import javax.swing.UIManager;
import javax.swing.plaf.synth.SynthLookAndFeel;
import org.cuadroanotacionapi.beans.Usuarios;
import org.cuadroanotacionapi.controller.UsuariosController;
import org.cuadroanotacionapi.generales.Mensajeria;


/**
 *
 * @author avbravo
 */
public class MenuForm extends javax.swing.JFrame {


    Usuarios usuarios1 = new Usuarios();
    UsuariosController  usuariosController1 = new UsuariosController();
           
       
    int x, y;
    int screenHeight;
    int screenWidth;
    private IconPolice iconPolice = new IconPolice();
//VentanaPopup splash = new VentanaPopup(1000) ;  // 1000 = 1 second 

    /**
     * Creates new form MenuForm
     */
    public MenuForm() {
        initComponents();
        try {
            //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(laf.getName())) {
                    UIManager.setLookAndFeel(laf.getClassName());
                    SynthLookAndFeel.setStyleFactory(
                            new MySynthStyleFactory(SynthLookAndFeel.getStyleFactory()));
                    break;
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        
 
        //
//        SesionLocal.imagenFondo = new javax.swing.ImageIcon(getClass().getResource("/org/gema/resources/logo/fondo_celeste.jpg"));


        jMenuBar1.setEnabled(false);
        jMenuBar1.setVisible(false);

        /*
         * Central JInternalFrame
         */
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension screenSize = tk.getScreenSize();
        this.screenHeight = screenSize.height;
        this.screenWidth = screenSize.width;
        this.x = (int) (this.screenWidth / 4.0);

        //   this.y =(int) (this.screenHeight / 4.0);
        this.y = 1;
        //
        jInternalFrameLogin.setVisible(true);
        jInternalFrameLogin.setLocation(x, y);
        jInternalFrameUsuario.setVisible(false);
        System.out.println("version " + SesionLocal.getVersion());
        jLabelVersionNumeroVersion.setText(SesionLocal.getVersion());
        jLabelVersionNumeroVersionUsuario.setText("Version: " + SesionLocal.getVersion());

        jTextFieldUsername.requestFocus();
        jTextField1.setText(SesionLocal.Version);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jDesktopPane1 = new javax.swing.JDesktopPane();
        jInternalFrameUsuario = new javax.swing.JInternalFrame();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabelUsername = new javax.swing.JLabel();
        jLabelVersionNumeroVersionUsuario = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jInternalFrameLogin = new javax.swing.JInternalFrame();
        jPanel3 = new javax.swing.JPanel();
        jSeparator3 = new javax.swing.JSeparator();
        jLabel5 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jTextFieldUsername = new javax.swing.JTextField();
        jPasswordField1 = new javax.swing.JPasswordField();
        jButtonEntrar = new javax.swing.JButton();
        jButtonSalir = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabelVersionNumeroVersion = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenuAnotaciones = new javax.swing.JMenu();
        jMenuItemSeleccioneTemporada = new javax.swing.JMenuItem();
        jMenuItemAnotacionesResultadosPartidos = new javax.swing.JMenuItem();
        jMenuItemAnotacionesEditar = new javax.swing.JMenuItem();
        jMenuItemLiveScore = new javax.swing.JMenuItem();
        jMenuEquipos = new javax.swing.JMenu();
        jMenuItemUsuariosListar = new javax.swing.JMenuItem();
        jMenuItemUsuariosCrear = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        jMenuItemSalir = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("FEDEBEIS");
        setExtendedState(4);

        jDesktopPane1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jInternalFrameUsuario.setClosable(true);
        jInternalFrameUsuario.setMaximizable(true);
        jInternalFrameUsuario.setResizable(true);
        jInternalFrameUsuario.setTitle("Usuario");
        jInternalFrameUsuario.setVisible(true);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Usuario"));

        jLabel1.setText("Usuario");

        jLabelUsername.setText("jLabel2");

        jLabelVersionNumeroVersionUsuario.setText("0.1.0");

        jLabel8.setText("Version");

        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel8))
                .addGap(38, 38, 38)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelVersionNumeroVersionUsuario, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
                    .addComponent(jLabelUsername))
                .addGap(18, 18, 18)
                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(24, 24, 24))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabelUsername))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jLabelVersionNumeroVersionUsuario)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        jButton1.setText("Salir");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jInternalFrameUsuarioLayout = new javax.swing.GroupLayout(jInternalFrameUsuario.getContentPane());
        jInternalFrameUsuario.getContentPane().setLayout(jInternalFrameUsuarioLayout);
        jInternalFrameUsuarioLayout.setHorizontalGroup(
            jInternalFrameUsuarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jInternalFrameUsuarioLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jInternalFrameUsuarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jInternalFrameUsuarioLayout.createSequentialGroup()
                        .addGap(157, 157, 157)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(53, Short.MAX_VALUE))
        );
        jInternalFrameUsuarioLayout.setVerticalGroup(
            jInternalFrameUsuarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jInternalFrameUsuarioLayout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jInternalFrameUsuario.setBounds(10, 570, 440, 210);
        jDesktopPane1.add(jInternalFrameUsuario, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jInternalFrameLogin.setTitle("ENTRAR");
        jInternalFrameLogin.setVisible(true);

        jPanel4.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel2.setText("Usuario");

        jLabel6.setText("Password");

        jTextFieldUsername.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldUsernameActionPerformed(evt);
            }
        });

        jPasswordField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jPasswordField1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel6))
                .addGap(2, 2, 2)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTextFieldUsername, javax.swing.GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE)
                    .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jTextFieldUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGap(26, 26, 26)
                        .addComponent(jLabel6)))
                .addContainerGap(30, Short.MAX_VALUE))
        );

        jButtonEntrar.setText("Entrar");
        jButtonEntrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonEntrarActionPerformed(evt);
            }
        });

        jButtonSalir.setText("Salir");
        jButtonSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSalirActionPerformed(evt);
            }
        });

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/logofedebeis.png"))); // NOI18N

        jLabel9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/torneojuvenil2012.png"))); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 416, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(40, 40, 40)
                        .addComponent(jLabel5)))
                .addContainerGap())
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(59, 59, 59)
                        .addComponent(jButtonEntrar, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonSalir, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addGap(18, 18, 18)
                .addComponent(jLabel3)
                .addGap(37, 37, 37))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jButtonSalir, javax.swing.GroupLayout.DEFAULT_SIZE, 60, Short.MAX_VALUE)
                            .addComponent(jButtonEntrar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(18, 18, 18)
                        .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel5)
                        .addGap(29, 29, 29))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(49, 49, 49))))
        );

        jLabelVersionNumeroVersion.setText("0.0");

        jLabel7.setText("Version:");

        javax.swing.GroupLayout jInternalFrameLoginLayout = new javax.swing.GroupLayout(jInternalFrameLogin.getContentPane());
        jInternalFrameLogin.getContentPane().setLayout(jInternalFrameLoginLayout);
        jInternalFrameLoginLayout.setHorizontalGroup(
            jInternalFrameLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(jInternalFrameLoginLayout.createSequentialGroup()
                .addGap(43, 43, 43)
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabelVersionNumeroVersion, javax.swing.GroupLayout.PREFERRED_SIZE, 229, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jInternalFrameLoginLayout.setVerticalGroup(
            jInternalFrameLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jInternalFrameLoginLayout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jInternalFrameLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelVersionNumeroVersion)
                    .addComponent(jLabel7))
                .addGap(50, 50, 50))
        );

        jInternalFrameLogin.setBounds(120, 30, 530, 540);
        jDesktopPane1.add(jInternalFrameLogin, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jMenuBar1.setEnabled(false);

        jMenuAnotaciones.setText("Anotaciones");

        jMenuItemSeleccioneTemporada.setText("Seleccione Temporada");
        jMenuItemSeleccioneTemporada.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSeleccioneTemporadaActionPerformed(evt);
            }
        });
        jMenuAnotaciones.add(jMenuItemSeleccioneTemporada);

        jMenuItemAnotacionesResultadosPartidos.setText("Resultados Partido");
        jMenuItemAnotacionesResultadosPartidos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemAnotacionesResultadosPartidosActionPerformed(evt);
            }
        });
        jMenuAnotaciones.add(jMenuItemAnotacionesResultadosPartidos);

        jMenuItemAnotacionesEditar.setText("Modificar Anotacion");
        jMenuItemAnotacionesEditar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemAnotacionesEditarActionPerformed(evt);
            }
        });
        jMenuAnotaciones.add(jMenuItemAnotacionesEditar);

        jMenuItemLiveScore.setText("Live Score");
        jMenuItemLiveScore.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemLiveScoreActionPerformed(evt);
            }
        });
        jMenuAnotaciones.add(jMenuItemLiveScore);

        jMenuBar1.add(jMenuAnotaciones);

        jMenuEquipos.setText("Usuarios");

        jMenuItemUsuariosListar.setText("Listar");
        jMenuItemUsuariosListar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemUsuariosListarActionPerformed(evt);
            }
        });
        jMenuEquipos.add(jMenuItemUsuariosListar);

        jMenuItemUsuariosCrear.setText("Crear");
        jMenuItemUsuariosCrear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemUsuariosCrearActionPerformed(evt);
            }
        });
        jMenuEquipos.add(jMenuItemUsuariosCrear);

        jMenuBar1.add(jMenuEquipos);

        jMenu1.setText("Salir");

        jMenuItemSalir.setText("Salir");
        jMenuItemSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSalirActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItemSalir);

        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jDesktopPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 1519, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jDesktopPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 1006, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItemSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSalirActionPerformed
        // TODO add your handling code here:
        System.exit(0);
    }//GEN-LAST:event_jMenuItemSalirActionPerformed

private void jTextFieldUsernameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldUsernameActionPerformed
    // TODO add your handling code here:
}//GEN-LAST:event_jTextFieldUsernameActionPerformed

private void jPasswordField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPasswordField1ActionPerformed
    // TODO add your handling code here:
    Login();
}//GEN-LAST:event_jPasswordField1ActionPerformed

private void jButtonEntrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonEntrarActionPerformed
    // TODO add your handling code here:
    Login();


}//GEN-LAST:event_jButtonEntrarActionPerformed

private void jButtonSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSalirActionPerformed
    // TODO add your handling code here:
    System.exit(0);
}//GEN-LAST:event_jButtonSalirActionPerformed

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField1ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
System.exit(1);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jMenuItemAnotacionesResultadosPartidosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAnotacionesResultadosPartidosActionPerformed
        AnotacionesFrame anotaciones = new AnotacionesFrame();
        anotaciones.setVisible(true);
        anotaciones.setLocation(1, 1);
        jDesktopPane1.add(anotaciones);
    }//GEN-LAST:event_jMenuItemAnotacionesResultadosPartidosActionPerformed

    private void jMenuItemAnotacionesEditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAnotacionesEditarActionPerformed
   AnotacionesCambiarFrame anotacionesEditar = new AnotacionesCambiarFrame();
        anotacionesEditar.setVisible(true);
        anotacionesEditar.setLocation(1, 1);
        jDesktopPane1.add(anotacionesEditar);
    }//GEN-LAST:event_jMenuItemAnotacionesEditarActionPerformed

    private void jMenuItemSeleccioneTemporadaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSeleccioneTemporadaActionPerformed
    SelectorTemporadas selectorTemporadas = new SelectorTemporadas();
       selectorTemporadas.setVisible(true);
       selectorTemporadas.setLocation(x, y);
        jDesktopPane1.add(selectorTemporadas);
    }//GEN-LAST:event_jMenuItemSeleccioneTemporadaActionPerformed

    private void jMenuItemUsuariosListarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemUsuariosListarActionPerformed
      EquiposListar equiposListar = new EquiposListar();
       equiposListar.setVisible(true);
       equiposListar.setLocation(x, y);
        jDesktopPane1.add(equiposListar);
    }//GEN-LAST:event_jMenuItemUsuariosListarActionPerformed

    private void jMenuItemUsuariosCrearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemUsuariosCrearActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItemUsuariosCrearActionPerformed

    private void jMenuItemLiveScoreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemLiveScoreActionPerformed
LivescoreFrame livescoreFrame= new LivescoreFrame();
  livescoreFrame.setVisible(true);
//      livescoreFrame.setLocation(x, y);
        jDesktopPane1.add(livescoreFrame);
    }//GEN-LAST:event_jMenuItemLiveScoreActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new MenuForm().setVisible(true);
            }
        });
    }

    private void Login() {
        try {
           
            usuarios1.setUsername(jTextFieldUsername.getText());
            String password = new String(this.jPasswordField1.getPassword());
            String passworddb = "";

            SesionLocal.setUsername(jTextFieldUsername.getText());

            Usuarios usuarios = usuariosController1.findByPrimaryKey(usuarios1);
            if (usuarios == null) {
                Mensajeria.Mensaje(" No existe un usuario con ese username");
                return;
            } else {
                usuarios1 = usuarios;
                passworddb = usuarios1.getPassword();
                if (!passworddb.equals(password)) {
                    Mensajeria.Mensaje("El password no es correcto");
                    return;
                }
                String dbActivo = usuarios1.getActivo();
                dbActivo = dbActivo.toLowerCase();
                if (!dbActivo.equals("si")) {
                    Mensajeria.Mensaje("Este usario no esta activo para usar el sistema");
                    return;
                }

             
                SesionLocal.setNombreusuario(usuarios1.getUsuario());

                 jMenuBar1.setEnabled(true);
                jMenuBar1.setVisible(true);
                jInternalFrameLogin.setVisible(false);
//                jInternalFrameUsuario.setVisible(true);

                jLabelUsername.setText(SesionLocal.getNombreusuario());

             
                jLabelVersionNumeroVersionUsuario.setText(SesionLocal.getVersion());
               SelectorTemporadas selectorTemporadas = new SelectorTemporadas();
       selectorTemporadas.setVisible(true);
       selectorTemporadas.setLocation(x, y);
        jDesktopPane1.add(selectorTemporadas);

            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "botonEntrar()");
        }
    }

    class IconPolice implements VetoableChangeListener {

        public void vetoableChange(PropertyChangeEvent ev)
                throws PropertyVetoException {
            String name = ev.getPropertyName();
            if (name.equals(JInternalFrame.IS_ICON_PROPERTY)
                    && (ev.getNewValue() == Boolean.TRUE)) {
                JInternalFrame[] frames = jDesktopPane1.getAllFrames();
                int count = frames.length;
                int nonicons = 0; // how many are not icons?
                for (int i = 0; i < count; i++) {
                    if (!frames[i].isIcon()) {
                        nonicons++;
                    }
                }
                if (nonicons <= 1) {
                    throw new PropertyVetoException("Invalid Iconification!",
                            ev);
                }
            }
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButtonEntrar;
    private javax.swing.JButton jButtonSalir;
    private javax.swing.JDesktopPane jDesktopPane1;
    private javax.swing.JInternalFrame jInternalFrameLogin;
    private javax.swing.JInternalFrame jInternalFrameUsuario;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabelUsername;
    private javax.swing.JLabel jLabelVersionNumeroVersion;
    private javax.swing.JLabel jLabelVersionNumeroVersionUsuario;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenuAnotaciones;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenu jMenuEquipos;
    private javax.swing.JMenuItem jMenuItemAnotacionesEditar;
    private javax.swing.JMenuItem jMenuItemAnotacionesResultadosPartidos;
    private javax.swing.JMenuItem jMenuItemLiveScore;
    private javax.swing.JMenuItem jMenuItemSalir;
    private javax.swing.JMenuItem jMenuItemSeleccioneTemporada;
    private javax.swing.JMenuItem jMenuItemUsuariosCrear;
    private javax.swing.JMenuItem jMenuItemUsuariosListar;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPasswordField jPasswordField1;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextFieldUsername;
    // End of variables declaration//GEN-END:variables
}
